package com.yxp423.ssmempl.controller;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.yxp423.ssmempl.bean.EmplLog;
import com.yxp423.ssmempl.service.IEmplLogService;
import com.yxp423.ssmempl.utils.base.AjaxResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description: java类作用描述
 * @Author: yxp
 * @CreateDate: 2019-05-09 18:44
 * @Version: 1.0
 */
@Controller
@RequestMapping("/empl")
public class EmplLogController {

	@Autowired
	IEmplLogService emplLogService;


	@GetMapping("/writediary")
	public String toWriteLogPage() {


		return "empl/empl_log";
	}


	@GetMapping("/addEmplLog")
	public String toAddLog(){

		return "empl/add_empl_log";

	}
	@GetMapping("/auditlogs")
	public String toReviewLog(){

		return "/empl/review_empl_log";
	}

	@GetMapping("/submitEmpl")
	@ResponseBody
	@ApiOperation("提交日志申请")
	public AjaxResult submitEmpl(EmplLog emplLog,String date){


		emplLog.setLogTime(DateUtil.parse(date));
		AjaxResult result = emplLogService.saveEmplLog(emplLog);

		return result;
	}

	@GetMapping("/getEmplLog")
	@ResponseBody
	public AjaxResult getEmplLog(){

		return emplLogService.getEmplLog();
	}

	@GetMapping("/deleteLog")
	@ResponseBody
	public AjaxResult deleteLog(EmplLog emplLog){

		return emplLogService.deleteEmplLog(emplLog);

	}

	@GetMapping("/getmyreviewlogs")
	@ResponseBody
	public AjaxResult getMyReviewLogs(EmplLog emplLog){

		return emplLogService.getMyReviewLogs(emplLog);
	}


	@GetMapping("/reviewLog")
	@ResponseBody
	public AjaxResult reviewLog(EmplLog emplLog){

		return emplLogService.reviewLog(emplLog);
	}


}
